package com.rest.demo.functional.strean;

import java.util.Arrays;
import java.util.List;

/**
 * @author Administrator
 * @decription
 * @Date 2018-01-29 15:44
 */
public class StreamDemo2 {

    public static void main(String[] args) {
        List<String> list = Arrays.asList("a1","a2","c2","c1","b2");
        list.stream()
                .filter(str -> str.startsWith("c"))
                .map(String::toUpperCase)
                .sorted()
                .forEach(System.out::println);

        Arrays.stream(new int[]{1,2,3})
                .map(n -> n * 2 + 1)
                .average()
                .ifPresent(System.out::println);

        Arrays.stream(new String[]{"a1","b2","c3"})
                .map(str -> str.substring(1))
                .mapToInt(Integer::parseInt)
                .forEach(num -> System.out.print(num+" "));
    }
}
